package com.neusoft.news.controller.clue;

import com.neusoft.news.bean.Clue;
import com.neusoft.news.controller.BaseServlet;
import com.neusoft.news.dao.ClueDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 线索列表
 *
 * @author wh
 * @ClassName: ClueListServlet
 * @Description: 线索列表
 * @date 2021年5月23日
 * @since JDK 1.8
 */
@WebServlet("/clueList")
public class ClueListServlet extends BaseServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
        resp.setContentType("text/html;charset=utf-8");
        ClueDao clueDao = new ClueDao();
        List<Clue> clues = clueDao.findAllClue(0);
        System.out.println(clues);
        req.setAttribute("clues", clues);
        req.getRequestDispatcher("/WEB-INF/jsp/clue.jsp")
                .forward(req, resp);
    }

}
